package com.hzz.hellomp;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzz.hellomp.entity.User;
import com.hzz.hellomp.mapper.UserMapper;
import com.hzz.hellomp.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class T3 {
//    先配置MybatisPuls的配置文件
//     设置全局逻辑删除字段为deleted
//    mybatis-plus.global-config.db-config.logic-delete-field=deleted
//     设置逻辑字段删除状态为1
//    mybatis-plus.global-config.db-config.logic-delete-value=1
//     设置逻辑字段未删除状态为0
//    mybatis-plus.global-config.db-config.logic-not-delete-value=0
    @Autowired
    UserMapper userMapper;
    @Autowired
    UserService userservice;
    @Test
    public void testLogicDelete() {
        userMapper.deleteById(1);
        userMapper.selectList(null);
    }

    @Test
    public void testPageService(){
        Page<User> page = new Page<>(2,2);
        Page<User> userPage = userservice.page(page);
        userPage.getRecords().forEach(System.out::println);
    }
    @Test
    public void testPageMapper(){
        IPage<User> page =new Page<>(2,3);
        IPage<User> userIPage = userMapper.selectPage(page, null);
        userIPage.getRecords().forEach(System.out::println);
    }

    @Test
    public void testPageEmail(){
        IPage<User> page = new Page<>(2,2);
        List<User> userIPage = userMapper.selectEmail(page);
        System.out.println("userIPage = " + userIPage);
    }
}
